package com.ruoyi.web.controller.system;

import com.ruoyi.system.domain.CampusContact;
import com.ruoyi.system.domain.Result;
import com.ruoyi.system.service.CampusContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/hospital/contact")
public class CampusContactController {
    @Autowired
    private CampusContactService contactService;

    @GetMapping("/byCampus/{campusId}")
    public Result<List<CampusContact>> listByCampusId(@PathVariable Long campusId) {
        List<CampusContact> list = contactService.listByCampusId(campusId);
        return Result.success(list);
    }

    @GetMapping("/{id}")
    public Result<CampusContact> getById(@PathVariable Long id) {
        CampusContact contact = contactService.getById(id);
        return Result.success(contact);
    }

    @PostMapping("/save")
    public Result<Integer> save(@RequestBody CampusContact contact) {
        int result = contactService.save(contact);
        return Result.success(result);
    }

    @PutMapping("/update")
    public Result<Integer> update(@RequestBody CampusContact contact) {
        int result = contactService.update(contact);
        return Result.success(result);
    }

    @DeleteMapping("/delete/{id}")
    public Result<Integer> delete(@PathVariable Long id) {
        int result = contactService.deleteByCampusId(id);
        return Result.success(result);
    }
}
